<div class="easyui-panel" title="班级成绩管理" data-options="fit:true" style="display: flex; flex-direction: column;">
	<p style="flex-flow: 0;">
		<label> 选择班级：</label>
		<input id="class" class="easyui-combobox" data-options="
			url:'banji/list',
			valueField:'id',
			textField:'name',
			panelHeight:'auto',
			editable:false,
			icons:[{
		        iconCls:'icon-clear',
		        handler: function(e){
		       	 $(e.data.target).textbox('clear');
		        	$('#div2').hide();
		        }
		  		  }],
		" />
		<label> 选择课程：</label>
		<input id="course" class="easyui-combobox" data-options="
			url:'course/list',
			valueField:'id',
			textField:'name',
			panelHeight:'auto',
			editable:false,
			icons:[{
		        iconCls:'icon-clear',
		        handler: function(e){
		       	 	$(e.data.target).textbox('clear');
		        	$('#div2').hide();
		        }
		  	}],
		" />
		<button class="easyui-linkbutton" data-options="iconCls:'icon-search'" id="cx1">查询</button>
	</p>
	<div id="div2" style="flex-grow: 1; display: none; ">
		<table id="bjcj1">
			<thead>
				<tr>
					<th data-options="field:'id',hidden:true">ID</th>
					<th width="200" data-options="field:'student',sortable: true,formatter:function(val,row,index){
							return row.student.stuNo;
							}">学号</th>
					<th width="300" data-options="field:'name',formatter:function(val,row,index){
							return row.student.name;
							}">姓名</th>
					<th width="300" data-options="field:'course',formatter:function(val,row,index){
							return row.course.name;
							}">课程</th>
					<th width="200" data-options="field:'grade',formatter:formatOper">成绩</th>
				</tr>

			</thead>

		</table>
	</div>
		

	<script type="text/javascript">
   
	$(function(){
		var grid = $('#bjcj1');
		$('#cx1').bind('click',function(){
			var bjId=$('#class').combobox('getValue');
			var kcId=$('#course').combobox('getValue');
			if(bjId==0||kcId==0){
					$('#div2').hide();
					return;
				}else{
					$('#div2').show();
					cjChange(bjId,kcId);
			}
		
			grid.datagrid({
				fit: true,
				url: 'grade/page?bjId='+bjId+'&kcId='+kcId,
				singleSelect: true,
				fitColumns: true,
				autoRowHeight: true,
				striped: true,
				idField: 'id',
				sortName: 'id',
				sortOrder: 'asc',
				pageList: [5, 10, 20, 30],
				pagination: true,
			});
	
		});
		
	})
	 function formatOper(val, row, index) {   
	 	if(row.grade==null){

           row.grade=0;
		 	}
		 		 return '<input id="input" value="'+row.grade+'"/>';
        }

	$("input[id='input']").numberbox({
	    min:0,
	    precision:0
	});
	function cjChange(bjId,kcId){
		$('#bjcj1').datagrid($.extend({},$.crudgrid.defaults,{
			url:'grade/page?bjId='+bjId+"&kcId="+kcId,
			onLoadSuccess:function(data){
		            $("input[id='input']").numberbox({
		            	onChange:function(grade,oldgrade){
			            	var grid=$('#bjcj1').datagrid('getSelected');
							xg(grid.id,grade);
			            }
			        });  
		   	}
		}))
	};
	function xg(id,grade){
		if(!(/^[0-9]\d*$/.test(grade))){
			$.messager.alert('提示ʾ','请输入正整数','info');
			return;
		};
	$.post('grade/cjChange',{id:id,grade:grade},function(data){});
}
	</script>
</div>
